Auth()
var number = '';
var name = '';
var classId = '';
//搜索
$('#search_prod').on('click', function() {
	var productNum = $('#pro_num').val();
	var productName = $('#pro_name').val();
	var className = jQuery("#pro_type  option:selected").val();
	if(productNum == '' || productNum == undefined) {
		productNum = ''
	}
	if(productName == '' || productName == undefined) {
		productName = ''
	}
	number = productNum;
	name = productName;
	classId = className;
	dhList(1, number, name, classId, true);
})
$('#reset').on('click', function() {
	$('#pro_num').val('');
	$('#pro_name').val('');
	$("#pro_type").find("option[value='']").attr("selected", true);
	dhList(1, '', '', '', true);
})
dhList(1, number, name, classId, true)

function dhList(page, number, name, classId, init) {
	var hdObj = {
		number: number,
		name: name,
		classId: classId,
		pageNum: page,
		pageSize: 5,
	}
	$.ajax({
		type: "post",
		url: apicom + "/score/getExchangeInfo",
		async: true,
		data: hdObj,
		success: function(res) {
			if(typeof res == 'string') {
				res = JSON.parse(res);
			}
			console.log(res)
			if(res.code == 200) {
				//				console.log(res)
				var dataScourse = res.data;
				if(dataScourse.length == 0) {
					$("#jf_page").hide();
					list(dataScourse);
//					$('tbody').html("<div class='center_kong'><img src='../img/f_2.png'/><p>暂无兑换！</p></div>");
					return false;
				}
				list(dataScourse);
				$("#jf_page").show();
				all_num = res.pages;
				/* 分页 */
				if(init == true) {
					$("#jf_page").createPage({
						pageNum: all_num, //总页码
						current: 1, //当前页
						shownum: 7, //每页显示个数
						showPageNum: false, //显示总页数
						showToPage: false, //显示跳转页码
						backfun: function(e) {
							hdList(e.current, number, name, classId, false);
						}
					});
				}
			} else {
				tips('暂无咨询')
			}
		},
		error: function(err) {
			console.log(err)
		}
	})
}

function list(content) {
	var ss = ''
	for(var i = 0; i < content.length; i++) {
		ss += '<tr data-id="'+ content[i].id +'"><td>' + content[i].number + '</td><td>' + content[i].name + '</td><td>' + content[i].score + '</td><td>' + content[i].num + '</td><td>' + content[i].className + '</td><td>' + content[i].status + '</td><td class="duihuan">兑换</td></tr>'
	}
	$('tbody').html(ss)
}
//点击兑换物品
var changeId
$(document).on('click', '.duihuan', function() {
	if(localStorage.getItem('user_info')) {
		changeId = $(this).parent().attr('data-id')
		$('.mengban').css('display', 'block');
		$('.sign').css('display', 'block');
		$('.sign_team').css('display', 'none');
		$('.sign_close').css('display', 'none');
		console.log(changeId)
	} else {
		window.location.href = 'login.html'
	}
})
$('.btn_yes').on('click',function(){
		if(localStorage.getItem('user_info')) {
		var joinObj = {
			uuid: uuid,
			loginId: id,
			changeId:changeId,
			loginType:is_team
		}
		console.log(joinObj)
		$.ajax({
			type: "post",
			url: apicom + "/score/toChange",
			async: true,
			data: joinObj,
			success: function(res) {
				if(res.code == 200) {
					$('.mengban').css('display', 'block');
					$('.sign').css('display', 'none');
					$('.sign_team').css('display', 'block');
					$('.sign_close').css('display', 'none');
					$('.dh_code').html(res.message);
				} else{
					$('.mengban').css('display', 'block');
					$('.sign').css('display', 'none');
					$('.sign_team').css('display', 'none');
					$('.sign_close').css('display', 'block');
					$('.error').html(res.message);
				}
			},
			error: function(err) {
				conosle.log(err)
			}
		});

	} else {
		window.location.href = 'login.html'
	}
})
//获取兑换物分类
$.ajax({
	type: "post",
	url: apicom + "/score/getClassInfo",
	async: true,
	success: function(res) {
		var data = res.data;
		var ss = '';
		for(var i = 0; i < data.length; i++) {
			ss += '<option value="' + data[i].id + '">' + data[i].name + '</option>'
		}
		$("#pro_type	").append(ss);
	},
	error: function(err) {

	}
});
//取消兑换
$('.btn_close').on('click', function() {
	$('.mengban').css('display', 'none');
//	$('.sign').css('display', 'none');
//	$('.sign_team').css('display', 'none');
})
$('.btn_close1').on('click', function() {
	$('.mengban').css('display', 'none');
//	$('.sign').css('display', 'none');
//	$('.sign_team').css('display', 'none');
	dhList(1, number, name, classId, true)
})
$('.close_s').on('click', function() {
	$('.mengban').css('display', 'none');
//	$('.sign').css('display', 'none');
//	$('.sign_team').css('display', 'none');
	dhList(1, number, name, classId, true)
})